﻿using Mars.Event;
using Mars.Module;
using Mars.Network;

namespace Mars.Network
{
    public static class GameContext
    {
        private static IEventManager _eventManager;

        public static IEventManager EventManager
        {
            get
            {
                if (_eventManager == null)
                {
                    _eventManager = ModuleManager.CreateModule(typeof(EventManager)) as IEventManager;
                }
                
                return _eventManager;
            }
        }
        
        //默认网络频道
        public const string CHANNEL_NAME = "network";
        
        private static INetworkManager _networkManager;
        public static INetworkManager NetworkManager
        {
            get
            {
                if (_networkManager == null)
                {
                    _networkManager = ModuleManager.CreateModule(typeof(NetworkManager)) as INetworkManager;
                }
                
                return _networkManager;
            }
        }

        public static void Clear()
        {
            _eventManager = null;
            _networkManager = null;
        }
    }
}